<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
   <head>
      <title>录入期刊论文</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<link rel="stylesheet" href="../../css/vip.css" type="text/css">
    <script type="text/javascript" src="../../js/showNewDiv.js"></script>
    <link rel="stylesheet" type="text/css" href="../../js/extjs/resources/css/ext-all.css"/>
    <script type="text/javascript" src="../../js/FoshanRen.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js">
  <script type="text/javascript" charset="utf-8" src="../../js/extjs/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/extjs/ext-all.js"></script>
     <SCRIPT language=JavaScript src="../../js/jquery.js"></SCRIPT>
    <script language="javascript">
    function deleteItem(id){
	 if(confirm("你确定要删除")){
	    $.get("paperQuery_deleteDocument.action?document.id="+id,
	    function(data){
	    $("#"+id).remove();
	    alert(data);
	    });
      }
    }
   function addWordComponent()
   {   
        var tr = document.createElement('tr');
        tr.setAttribute("bgcolor", "f5f5f5");
        var td1 = document.createElement('td');
        td1.setAttribute("width", "25%");
        var td2 = document.createElement('td');
        td2.setAttribute("width", "75%");
       
        var uploadHTML = document.createElement('input');
        uploadHTML.setAttribute("type","file");
        uploadHTML.setAttribute("name","word");
        var last = document.getElementById("last");
        var tables = last.parentNode;
       
        tr.appendChild(td1);
        td2.appendChild(uploadHTML);
        tr.appendChild(td2);
        tables.insertBefore(tr,last);
        var button = document.createElement("input");
        button.type = "button";
	    button.value = "删 除"
	    td2.appendChild(button);
        button.onclick = function()
	    {
		tables.removeChild(tr);
	   }
    }
    function addPDFComponent()
   {   
        var tr = document.createElement('tr');
        tr.setAttribute("bgcolor", "f5f5f5");
        var td1 = document.createElement('td');
        td1.setAttribute("width", "25%");
        var td2 = document.createElement('td');
        td2.setAttribute("width", "75%");
       
        var uploadHTML = document.createElement('input');
        uploadHTML.setAttribute("type","file");
        uploadHTML.setAttribute("name","pdf");
        var ongoing = document.getElementById("pdf");
        var tables = ongoing.parentNode;
        
        tr.appendChild(td1);
        td2.appendChild(uploadHTML);
        tr.appendChild(td2);
        tables.insertBefore(tr,ongoing);
        var button = document.createElement("input");
        button.type = "button";
	    button.value = "删 除"
	    td2.appendChild(button);
        button.onclick = function()
	    {
		tables.removeChild(tr);
	   }
    }
    
function len(s){//获取字符串的字节长度
  return s.length+(s.match(/[^\x00-\xff]/g) ||"").length;//加上匹配到的全角字符长度
}
String.prototype.trim=function(){
return this.replace(/(^\s*)|(\s*$)/g,"");
}

function check(){
var reg=/^\d+$/;//判断是非负整数的正则表达式
var LEN400=400,LEN200=200,LEN20=20,LEN1000=1000,LEN100=100;
var f,paperTittle,firstAuthor,secondAuthor,thirdAuthor,fourthAuthor,fifthAuthor,sixthAuthor,publicationYear,publicationJournal,volume,issue,startPage,endPage,keyWord,paperAbstract,reviewComments,note;
paperTittle=document.getElementById("paperTittle").value;
if(paperTittle.trim()==""){
  alert("论文题目不可为空！");
  return false;
}
firstAuthor=document.getElementById("firstAuthor").value;
if(firstAuthor.trim()==""){
  alert("第一作者不可为空！");
  return false;
}

publicationYear=document.getElementById("publicationYear").value;
var myDate = new Date();
if(publicationYear.trim() != ""){
	if(publicationYear <= 1980 || publicationYear > myDate.getYear())
	{ 
   		alert("年份格式不正确!");
  		return false;
	} 
}

volume=document.getElementById("volume").value;
if(volume.trim() != ""&&!reg.test(volume)){
  alert("卷只能是0或正整数！");
  return false;
}

issue=document.getElementById("issue").value;
if(issue.trim() != ""&&!reg.test(issue)){
  alert("期只能是0或正整数！");
  return false;
}
startPage=document.getElementById("startPage").value;
if(startPage.trim() != ""&&!reg.test(startPage)){
  alert("开始页码只能是0或正整数！");
  return false;
}

endPage=document.getElementById("endPage").value;
if(endPage.trim() != ""&&!reg.test(endPage)){
  alert("结束页码只能是0或正整数！");
  return false;
}

if(startPage > endPage){
	alert("开始页码不能大于结束页码！ ");
	return false;
}

paperAbstract=document.getElementById("paperAbstract").value;
if(paperAbstract!=""){
  if(len(paperAbstract)>LEN1000){
  alert("摘要长度超过"+LEN1000+"字节！");
  return false;
}
}

reviewComments=document.getElementById("reviewComments").value;
if(reviewComments!=""){
  if(len(reviewComments)>LEN100){
  alert("评审意见长度超过"+LEN100+"字节！");
  return false;
}
}

note=document.getElementById("note").value;
if(note!=""){
  if(len(note)>LEN100){
  alert("备注长度超过"+LEN100+"字节！");
  return false;
}
}

//f=document.getElementById("myform");
//f.submit();
}

</script> 
  </head> 
 <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  <s:form id="myform" action="journalAdd_update" namespace="/admin" enctype="multipart/form-data"  method="post" onsubmit="return check();">
  <table id="tables" width="98%" border="0" cellspacing="1" cellpadding="3" align="center">
  <s:hidden name="journalPaper.id" value="%{#journalPaper.id}"/>
    <tr bgcolor="6f8ac4"> 
      <td colspan="2" ><font color="#FFFFFF">期刊论文信息修改：</font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">论文题目：</div></td>
      <td width="75%"><s:textfield name="journalPaper.paperTittle" id="paperTittle" value="%{#journalPaper.paperTittle}" size="60" maxlength="400"/><font color="#FF0000">*</font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">第一作者：</div></td>
      <td width="75%"><s:textfield name="journalPaper.firstAuthor" id="firstAuthor" value="%{#journalPaper.firstAuthor}" maxlength="20"/><font color="#FF0000">*</font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">第二作者：</div></td>
      <td width="75%"><s:textfield name="journalPaper.secondAuthor" value="%{#journalPaper.secondAuthor}" maxlength="20"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">第三作者：</div></td>
      <td width="75%"><s:textfield name="journalPaper.thirdAuthor" value="%{#journalPaper.thirdAuthor}" maxlength="20"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">第四作者：</div></td>
      <td width="75%"><s:textfield name="journalPaper.fourthAuthor" value="%{#journalPaper.fourthAuthor}" maxlength="20"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">第五作者：</div></td>
      <td width="75%"><s:textfield name="journalPaper.fifthAuthor" value="%{#journalPaper.fifthAuthor}" maxlength="20"/></td>
    </tr>
    <tr bgcolor="f5f5f5">
      <td width="25%"> <div align="right">第六作者：</div></td>
      <td width="75%"><s:textfield name="journalPaper.sixthAuthor" value="%{#journalPaper.sixthAuthor}" maxlength="20"/></td>
    </tr>
     <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">发表年份：</div></td>
      <td width="75%"><s:textfield name="journalPaper.publicationYear" id="publicationYear" value="%{#journalPaper.publicationYear}" maxlength="4"/></td>
    </tr> 
    <tr bgcolor="f5f5f5"> 
      <td width="25%" valign="top"><div align="right">发表期刊：</div></td>
      <td width="75%"><s:textfield name="journalPaper.publicationJournal" value="%{#journalPaper.publicationJournal}" size="60" maxlength="200"/></td>
	</tr>
	<tr bgcolor="f5f5f5"> 
      <td width="25%" valign="top"><div align="right">卷：</div></td>
      <td width="75%"><s:textfield name="journalPaper.volume" id="volume" value="%{#journalPaper.volume}" maxlength="10"></s:textfield></td>
	</tr>
	<tr bgcolor="f5f5f5"> 
      <td width="25%" valign="top"><div align="right">期： </div></td>
      <td width="75%"><s:textfield name="journalPaper.issue" id="issue" value="%{#journalPaper.issue}" maxlength="10"></s:textfield> </td>
	</tr>
	<tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">期刊类别：</div></td>
      <td width="75%"><s:radio name="journalPaper.journalLevel" list="#{'国际':'国际','一级':'一级','核心':'核心'}" value="%{#journalPaper.journalLevel}"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">开始页码：</div></td>
      <td width="75%"><s:textfield name="journalPaper.startPage" id="startPage" value="%{#journalPaper.startPage}" maxlength="10"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">结束页码：</div></td>
      <td width="75%"><s:textfield name="journalPaper.endPage" id="endPage" value="%{#journalPaper.endPage}" maxlength="10"/></td>
    </tr>
     <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">论文状态：</div></td>
      <td width="75%"><s:radio name="journalPaper.state" list="#{'已投出':'已投出','已录用':'已录用','已发表':'已发表'}" value="%{#journalPaper.state}"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">关键字：</div></td>
      <td width="75%"><s:textfield name="journalPaper.keyWord" value="%{#journalPaper.keyWord}" maxlength="100"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">摘要：</div></td>
      <td width="75%"><s:textarea name="journalPaper.paperAbstract" id="paperAbstract" cols="60" rows="8" value="%{#journalPaper.paperAbstract}"></s:textarea></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%" valign="top"><div align="right">评审意见：</div></td>
      <td width="75%"><s:textarea name="journalPaper.reviewComments" id="reviewComments" cols="60" rows="4" value="%{#journalPaper.reviewComments}"></s:textarea></td>
	</tr>
	<tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">是否被SCI收录：</div></td>
      <td width="75%"><s:radio name="journalPaper.SCiinlude" list="#{'true':'是','false':'否'}" value="%{#journalPaper.SCiinlude}"/></td>
    </tr>
	<tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right">是否被EI收录：</div></td>
      <td width="75%"><s:radio name="journalPaper.EIInclude" list="#{'true':'是','false':'否'}" value="%{#journalPaper.EIInclude}"/></td>
    </tr>
     <tr bgcolor="f5f5f5"> 
      <td width="25%" valign="top"> <div align="right">备注：</div></td>
      <td width="75%"><s:textarea name="journalPaper.note" id="note" cols="60" rows="2" value="%{#journalPaper.note}"></s:textarea></td>
	</tr>
     <tr bgcolor="f5f5f5"> 
        <td width="25%"> <div align="right">论文Word文档：</div></td>
        <td width="75%"></td>
      </tr>
      <s:iterator value="#journalPaper.word">
      <s:if test="%{documentType=='word'}">
     <tr bgcolor="f5f5f5" id="<s:property value="id"/>"> 
      <td width="25%"></td>
      <td width="75%">
      <font color="#0066FF"><s:property value="docName"/></font>
      <input type="button" value="删除" onClick="deleteItem(<s:property value="id"/>)"/>
      </td>
      </tr>
      </s:if>
    </s:iterator>
    <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right"></div></td>
       <td width="75%"><input type="button" class="frm_btn" onclick="addWordComponent();" value="添加文件" /> </td> 
    </tr>     
    <tr bgcolor="f5f5f5" id="last"> 
      <td width="25%"></td>
      <td width="75%"><font color="#0099FF">-------------------------------------------------------------------------</font></td>
      </tr>
     <tr bgcolor="f5f5f5"> 
        <td width="25%"> <div align="right">论文PDF文档：</div></td>
        <td width="75%"></td>
      </tr>
     <s:iterator value="#journalPaper.pdf">
      <s:if test="%{documentType=='pdf'}">
     <tr id="<s:property value="id"/>"  bgcolor="f5f5f5"> 
      <td width="25%"> </td>
      <td width="75%">
      <font color="#0066FF"><s:property value="docName"/></font>
      <input type="button" value="删除" onClick="deleteItem(<s:property value="id"/>)"/>
      </td>
      </tr>
      </s:if>
    </s:iterator>
    
      <tr bgcolor="f5f5f5"> 
      <td width="25%"> <div align="right"></div></td>
       <td width="75%"><input type="button" class="frm_btn" onclick="addPDFComponent();" value="添加文件" /></td> 
      </tr>
    <tr bgcolor="f5f5f5" id="pdf"> 
      <td width="25%"></td>
      <td width="75%"><font color="#0099FF">-------------------------------------------------------------------------</font></td>
      </tr>
    <tr bgcolor="f5f5f5"> 
      <td colspan="2"> <div align="center"> 
          <input type="submit" class="frm_btn" value=" 提 交 ">
          &nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="Button" value=" 返 回 " class="frm_btn" onclick="javascript:history.back()">
        </div></td>
    </tr>
  </table>
</s:form>
  </body>
</html>
